package mess;

public class LeeCode_70 {
    public static void main(String[] args) {
        System.out.println(climbStairs(3));
    }
    private static int climbStairs(int n) {
       /* if (n == 45)
            return 1836311903;
        if (n == 2)
            return 2;
        if (n == 1)
            return 1;
        return climbStairs(n - 1) + climbStairs(n - 2);*/
        if (n <= 2)
            return n;
        int[] dp = new int[]{1, 2};
        for (int i = 3; i <= n; i++) {
            int temp = dp[0] + dp[1];
            dp[0] = dp[1];
            dp[1] = temp;
        }
        return dp[1];
    }
}
